/**   
* @Title: FInt2.java 
* @Package net.gdface.sdk 
* @author guyadong   
* @date 2016年7月8日 上午9:35:59 
* @version V1.0   
*/
package net.gdface.sdk;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.Serializable;

/**
 * 通用整数2维向量对象(表示坐标,尺寸)
 * @author guyadong
 *
 */
public class FInt2 implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int x,y;
	/**
	 * 
	 */
	public FInt2() {
		this(0,0);
	}
	public FInt2(int x, int y) {
		this.x = x;
		this.y = y;
	}
	/**
	 * @return x
	 */
	public int getX() {
		return x;
	}
	/**
	 * @param x 要设置的 x
	 */
	public void setX(int x) {
		this.x = x;
	}
	/**
	 * @return y
	 */
	public int getY() {
		return y;
	}
	/**
	 * @param y 要设置的 y
	 */
	public void setY(int y) {
		this.y = y;
	}
	
	@Override
	public String toString() {
		ByteArrayOutputStream bo = new ByteArrayOutputStream();
		toStream(new PrintStream(bo));
		return bo.toString();
	}
	/**
	 * 以文本形式向{@link PrintStream}输出对象内容 
	 * @param stream
	 */
	public void toStream(PrintStream stream) {
		stream.printf("[%d,%d]",this.x,this.y);
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof FInt2)) {
			return false;
		}
		FInt2 other = (FInt2) obj;
		if (x != other.x) {
			return false;
		}
		if (y != other.y) {
			return false;
		}
		return true;
	}
}
